import React from 'react';

export default class FunctionAsChildren extends React.Component {
    render() {
        const Repeat = function(props) {
            let items = [];
            for (let i = 0; i < props.numTimes; i++) {
                items.push(props.children(i));
            }
            return <div>{items}</div>;
        }

        return (
            <Repeat numTimes={10}>
                {(index) => <div key={index}>This is item {index} in the list</div>}
            </Repeat>
        );
    }
}